package optimizers.ganeat;

import java.text.DecimalFormat;
public class CompatibilityDistance {
	public int nExcess;
	public int nDisjoint;
	public double avgWeightDifference;
	public int N;

	public CompatibilityDistance(int nExess, int nDisjoint,
			double avgWeightDifference, int N) {
		this.nExcess = nExess;
		this.nDisjoint = nDisjoint;
		this.avgWeightDifference = avgWeightDifference;
		this.N = N;
	}

	public double distance() {
		if (N == 0)
			return 0;
		return Constants.c1 * nExcess / N + Constants.c2 * nDisjoint / N
				+ Constants.c3 * avgWeightDifference;
	}

	public String toString() {
		return common.Static.df4.format(distance()) + "(" + nExcess + ","
				+ nDisjoint + ","
				+ common.Static.df4.format(avgWeightDifference) + ") " + N;
	}
}
